import { _decorator, Component, EventTouch, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('TouchCD')
export class TouchCD extends Component {

    @property
    cdTime: number = 2

    protected onLoad(): void {
        // this.node.on(Node.EventType.TOUCH_START, this.touchStart, this)
        this.node.on(Node.EventType.TOUCH_END, this.touchEnd, this)
    }

   

    private touchEnd(et: EventTouch) {
        // et.propagationImmediateStopped = false
        console.log("1111")

        if (this._isCD) {
            et.propagationImmediateStopped = false
            return
        } else {
            et.propagationImmediateStopped = true
        }
            

        this._isCD = true
        this.scheduleOnce(this.countCD, this.cdTime);
    }

    private _isCD = false
    countCD() {
        this._isCD = false
    }
}